package main

import "math/rand"

type Solution struct {
	m map[int][]int
}

func Constructor(nums []int) Solution {
	m := make(map[int][]int)
	for i, num := range nums {
		m[num] = append(m[num], i)
	}
	return Solution{
		m: m,
	}
}

func (this *Solution) Pick(target int) int {
	indices := this.m[target]
	if len(indices) == 0 {
		return -1
	}
	if len(indices) == 1 {
		return indices[0]
	}
	pick := rand.Intn(len(indices))
	return indices[pick]
}

func main() {

}
